// ----------------------------------
// RSDK Project: Sonic 1 Forever X Doki Doki Literature Club
// Script Description: BG
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 1 : TYPE_SEGA
private alias 75 : SPACING_VALUE
private alias -18 : X_OFFSET
private alias 2 : Y_OFFSET

private alias object.value0 : object.timer
private alias object.value1 : object.xMonika
private alias object.value2 : object.yMonika
private alias object.value3 : object.sMonika
private alias object.value4 : object.xSayori
private alias object.value5 : object.ySayori
private alias object.value6 : object.sSayori
private alias object.value7 : object.xYuri
private alias object.value8 : object.yYuri
private alias object.value9 : object.sYuri
private alias object.value10 : object.xNat
private alias object.value11 : object.yNat
private alias object.value12 : object.sNat

// Function declarations


event ObjectMain
	object.xSayori = screen.xcenter
	if screen.xsize == 320
		object.xSayori += 15
	else
		object.xSayori -= 30
	end if	

	if object.timer == 0
		object.ySayori = screen.ysize
		object.ySayori *= 2
	end if

	if object.timer >= 65
		object.iypos = screen.ysize
		object.iypos -= 70	
		
		temp0 = object.iypos
		temp0 -= object.ySayori
		Abs(temp0)

		temp1 = object.iypos
		temp1 -= object.ySayori

		//Make sure it's exactly in the spot
		if temp0 < 6
			if object.ySayori > object.iypos
				object.ySayori--
			else
				if object.ySayori < object.iypos
					object.ySayori++
				else
					object.ySayori = object.iypos
				end if
			end if
		else
			temp1 >>= 2
			object.ySayori += temp1
		end if	
	end if	

	object.xNat = screen.xcenter
	if screen.xsize == 320
		object.xNat += 15
	else
		object.xNat += 10
	end if	

	if object.timer == 0
		object.yNat = screen.ysize
		object.yNat *= 2
	end if

	if object.timer >= 80
		object.iypos = screen.ysize
		object.iypos -= 140	
		
		temp0 = object.iypos
		temp0 -= object.yNat
		Abs(temp0)

		temp1 = object.iypos
		temp1 -= object.yNat

		//Make sure it's exactly in the spot
		if temp0 < 6
			if object.yNat > object.iypos
				object.yNat--
			else
				if object.yNat < object.iypos
					object.yNat++
				else
					object.yNat = object.iypos
				end if
			end if
		else
			temp1 >>= 2
			object.yNat += temp1
		end if	
	end if	
	object.xYuri = object.xNat
	object.xYuri += 60

	if object.timer == 0
		object.yYuri = screen.ysize
		object.yYuri *= 2
	end if

	if object.timer >= 100
		object.iypos = screen.ysize
		object.iypos -= 100	
		
		temp0 = object.iypos
		temp0 -= object.yYuri
		Abs(temp0)

		temp1 = object.iypos
		temp1 -= object.yYuri

		//Make sure it's exactly in the spot
		if temp0 < 6
			if object.yYuri > object.iypos
				object.yYuri--
			else
				if object.yYuri < object.iypos
					object.yYuri++
				else
					object.yYuri = object.iypos
				end if
			end if
		else
			temp1 >>= 2
			object.yYuri += temp1
		end if	
	end if	

	if object.timer == 0
		object.yMonika = screen.ysize
		object.yMonika *= 2
	end if

	object.xMonika = object.xNat
	object.xMonika += 152

	if object.timer >= 120
		object.iypos = screen.ysize
		object.iypos -= 60	
		
		temp0 = object.iypos
		temp0 -= object.yMonika
		Abs(temp0)

		temp1 = object.iypos
		temp1 -= object.yMonika

		//Make sure it's exactly in the spot
		if temp0 < 6
			if object.yMonika > object.iypos
				object.yMonika--
			else
				if object.yMonika < object.iypos
					object.yMonika++
				else
					object.yMonika = object.iypos
				end if
			end if
		else
			temp1 >>= 2
			object.yMonika += temp1
		end if	
	end if	

	object.timer++
end event


event ObjectDraw
	if object[OPTIONS_SLOT].type != TypeName[Options]
		temp0 = object.xNat
		temp0 += X_OFFSET
		temp1 = object.yNat
		temp1 += Y_OFFSET
		if screen.xsize == 320
			temp0 += 25
			temp1 -= 10
		end if		
		DrawSpriteScreenXY(3, temp0, temp1)	
		temp0 = object.xYuri
		temp0 += X_OFFSET
		if screen.xsize == 320
			temp0 += 5
		end if				
		temp1 = object.yYuri
		temp1 += Y_OFFSET		
		DrawSpriteScreenXY(2, temp0, temp1)	
		temp0 = object.xMonika
		temp0 += X_OFFSET
		temp1 = object.yMonika
		temp1 += Y_OFFSET			
		object.scale = 1024
		DrawSpriteScreenFX(0, FX_SCALE, temp0, temp1)	
		temp0 = object.xSayori
		temp0 += X_OFFSET
		temp1 = object.ySayori
		temp1 += Y_OFFSET		
		DrawSpriteScreenXY(1, temp0, temp1)	
	end if	
end event


event ObjectStartup
	LoadSpriteSheet("DDLCMenu/Portraits.gif")
	SpriteFrame(-48, -84, 103, 159, 261, 1)  //0 Monika
	SpriteFrame(-58, -82, 97, 148, 70, 1) //1 Sayori
	SpriteFrame(-48, -75, 68, 130, 1, 1) //2 Natsuki	
	SpriteFrame(-46, -83, 92, 166, 168, 1) //3 Yuri

	// weird place to put it man
	EditMenuEntry(1, "Sonic 1 Forever X Doki Doki Literature Club", 1, 0)
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
